<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册页面</title>
</head>
<body>
	<center>
	<form action="add" method="post">
		<table>
			<tr>
				<td>用户名:</td>
				<td><input type="text" name="name" id="te"><span
					id="ts"></span></td>
			</tr>
			<tr>
				<td>公司名称:</td>
				<td><input type="text" name="hname"></td>
			</tr>
			<tr>
				<td>公司税号:</td>
				<td><input type="text" name="number"></td>
			</tr>
			<tr>
				<td>密码:</td>
				<td><input type="password" name="password" id="pas"></td>
			</tr>
			<tr>
				<td>确认密码:</td>
				<td><input type="password" name="upassword" id="upas"><span
					id="tp"></span></td>
			</tr>
			<tr>
				<td><input type="submit" value="注册"></td>
			</tr>
		</table>
		</form>
	</center>
	<script src="./public/js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {

			$("#te").focus(function() {

				$("#ts").html("请输入账号!");
			});
			$("#te").blur(function() {
				var name = $("#te").val();
				$.ajax({
					type : 'post',
					url : 'selectname',
					data : {
						'name' : name
					},
					dataType : 'json',
					error : function() {
						alert("error!");
					},

					success : function(result) {
						if (result == 1) {
							//alert("用户不可用");
							$("#ts").html("该应户名已存在");
							$("#ts").css("color", "red");
						} else if (result == 0) {
							//alert("用户可用!");
							$("#ts").html("该用户名可用");
							$("#ts").css("color", "green");

						}
					}

				});

			});
			/* ajax结束 */

			$("#upas").blur(function() {
				var pas = $("#pas").val();
				var upas = $("#upas").val();
				if (pas != upas) {
					$("#tp").html("两次密码不一致");
				}else{
					$("#tp").html("");
					}
			});
			/* 确认密码结束 */

			

		});
	</script>
</body>
</html>